package com.cll.learn.monitor.thread;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 描述信息:
 * 直接记录然后丢弃任务
 * @author CLL
 * @version 1.0
 * @date 2020/9/29 9:47
 */
public class DiscardAndRecordPolicy implements RejectedExecutionHandler {

    private static final Logger logger = LoggerFactory.getLogger(DiscardAndRecordPolicy.class);

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        logger.error("****** discard and record task. task = {}, executor = {}", JSONObject.toJSONString(r), JSONObject.toJSONString(executor));
    }

}
